<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<script type="text/javascript">
$('#member_accounts_datagrid').datagrid({   
    url:'${pageContext.request.contextPath}/memberController/memberAccounts.action',   
    columns:[[
        {field:'id',title:'序号'},
        {field:'regDate',title:'注册日期'},
        {field:'name',title:'客户名称'},   
        {field:'cardId',title:'卡号'},
        {field:'memberType',title:'会员类型',align:'center'},
        {field:'rechargeFee',title:'已缴纳的会费（元）',align:'right'},
        {field:'memberFee',title:'已扣除的年服务费（元）',align:'right'},
        {field:'consumeFee',title:'总的消费性会费（元）',align:'right'},
        {field:'totalConsumed',title:'已消费的金额（元）',align:'right'},
        {field:'balance',title:'消费性会费余额（元）',align:'right'}
    ]],
    onLoadSuccess:function(){
    	$('#member_accounts_datagrid').datagrid('appendRow', {
    		   'id':'',
    		   'regDate':'',
    		   'name':'',
    		   'cardId':'',
    		   'memberType':'<strong>合计</strong>',
    		   'rechargeFee':sumDouble("rechargeFee"),
    		   'memberFee':sumDouble("memberFee"),
    		   'consumeFee':sumDouble("consumeFee"),
    		   'totalConsumed':sumDouble("totalConsumed"),
    		   'balance':sumDouble("balance")});
    }
});
function sumDouble(colName) {
    var rows = $('#member_accounts_datagrid').datagrid('getRows');
    var total = 0;
    for (var i = 0; i < rows.length; i++) {
        total += parseFloat(rows[i][colName]);
        //total = total.toFixed(2);
    }
    return "<strong>" + total + "</strong>";
}
</script>
<div class="easyui-layout" data-options="fit : true,border : false">
	<div data-options="region:'center',border:false">
		<table id="member_accounts_datagrid"></table>
	</div>
</div>